layui.define(['xmSelect', 'tableExt'], function (exports) {
    var layer = layui.layer;
    var $ = layui.$;
    var pro = layui.pro;
    var table = layui.table;
    var form = layui.form;

    // 渲染
    table.render({
        elem: '#crud_table',
        url: '/api/systemDictType/page',
        cols: [function () {
            var arr = [
                {checkbox: true, fixed: true},
                {field: 'id', title: 'ID', width: 40, fixed: 'left'},
                {field: 'name', title: '字典名称', width: 180},
                {field: 'type', title: '字典类型', width: 180},
                {field: 'status', title: '状态（0正常 1停用）', width: 180},
                {title: '操作', fixed: 'right', toolbar: '#operatorCol'}
            ];
            return arr;
        }()],
        setUrl: "aaa/bbb/ccc",
        rowDelUrl: '/api/systemDictType/remove/',
        addUrl: '/api/systemDictType/save',
        addDialogElem: '#id_add_dialog'
    });

    // 搜索提交
    form.on('submit(crud_from)', function (data) {
        var field = data.field; // 获得表单字段
        // 执行搜索重载
        table.reload('crud_table', {
            page: {
                curr: 1 // 重新从第 1 页开始
            },
            where: field // 搜索的字段
        });
        return false; // 阻止默认 form 跳转
    });

    exports('dictTypeIndex', {});
});